package com.xxl.job.kettle.core.controller;

import com.xxl.job.kettle.core.entity.DiCategory;
import com.xxl.job.kettle.core.entity.KRepository;
import com.xxl.job.kettle.core.service.DiCategoryService;
import com.xxl.job.kettle.result.Result;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 实现功能：
 *
 * @author 作者[zk]
 * @version 1.0.00  2022-11-29 10:07
 */
@RestController
@RequestMapping("/dataCollection/dicategory")
//@Api(tags = "数据整合分类相关接口")
public class DiCategoryController extends BaseController<DiCategory, DiCategoryService> {
    /**
     * 添加目录
     *
     * @param param
     * @return 添加结果
     */
//    @ApiOperation(value = "添加目录")
    @PostMapping("/add")
    public Result add(@RequestParam Map<String, String> param) throws Exception {
        return service.add(param);
    }

    /**
     * 删除资源库目录并删除存在oracle的数据
     *
     * @param dirId
     * @param repId
     * @return {@link Result}
     */
//    @ApiOperation(value = "通过id删除资源库目录")
    @GetMapping("/delete")
    public Result delete(@RequestParam("dirId") String dirId, String repId) throws Exception {
        return service.delete(dirId, repId);
    }

    /**
     * 更新资源库目录
     *
     * @param param
     * @return {@link Result}
     */
//    @ApiOperation(value = "更新资源库目录")
    @PostMapping("/update")
    public Result update(@RequestParam Map<String, String> param) throws Exception {
        // 修改
        service.update(param);
        return Result.OK();
    }

    /**
     * @param id
     * @return
     */
//    @ApiOperation(value = "查询资源库目录树")
    @GetMapping("/findDiCateryByRep")
    public Result findDiCateryByRep(@RequestParam("id") String id) throws Exception {
        // 查询
        return Result.OK(service.findDiCategoryByRep(id));
    }

    /**
     * @param id
     * @return
     */
//    @ApiOperation(value = "查询资源库信息")
    @GetMapping("/findRepositoryById")
    public Result<KRepository> findRepositoryById(@RequestParam("id") String id) {
        return Result.OK(service.findRepositoryById(id));
    }
}
